package spark;

import fundamental.RegionServer;
import getinfo.GetRegionServerLoad;
import log.WriteToLog;
import singleobject.MemoryInfo;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class ServerDemo {


public static void main(String[] args) {
    try {
        WriteToLog.write("haha,start!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
        //1.创建一个服务器端Socket，即ServerSocket，指定绑定的端口，并监听此端口
        ServerSocket serverSocket=new ServerSocket(8888);
        Socket socket=null;
        //调用其构造函数，初始化三个跟region有关的MAP.
        MemoryInfo.getREGION().init();

        //开始从HBase读取请求信息
        GetRegionServerLoad.main(args);
//        for(String serverName : RegionServer.rsNameInCluster){
//            System.out.println(serverName);
//        }
        System.out.println("***服务器即将启动，等待客户端的连接***");
        //循环监听等待客户端的连接
        while(true){
            //调用accept()方法开始监听，等待客户端的连接
            socket=serverSocket.accept();
            //创建一个新的线程
            ServerThread serverThread=new ServerThread(socket);
            //启动线程
            serverThread.start();
        }
    } catch (IOException e) {
        e.printStackTrace();
    }catch(InterruptedException ex){
        ex.printStackTrace();
    }
}


}

